package collection;

import java.util.*;

public class ArrayToListDemo {
    public static void main(String[] args) {
        String[] array = {"我尼玛","我尼玛","我尼玛","我尼玛","我尼玛","我尼玛"};
        System.out.println("array:"+ Arrays.toString(array));

        List<String> list = Arrays.asList(array);
        System.out.println("list:"+list);

        list.set(1,"爱嫂子");
        System.out.println("list:"+list);
        System.out.println("array:"+Arrays.toString(array));

        array[2] = "哎呦";
        System.out.println("list:"+list);
        System.out.println("array:"+Arrays.toString(array));


        //错误
//        list.add("!!!!!");
//        System.out.println("list:"+list);
//        System.out.println("array:"+Arrays.toString(array));


        List<String> list2 = new ArrayList<>(list);//等同于先new再addAll()
        //Set<String> set = new HashSet<>(list);//等同于先new再addAll()

        System.out.println("list2:"+list2);
        list2.add("!!!");
        System.out.println("list2:"+list2);
    }
}
